GtkToolShell: Move vfunc default results to default implementations.
authorMurray Cumming <murrayc@murrayc.com>
Tue, 9 Aug 2011 14:55:01 +0000 (16:55 +0200)
committerMurray Cumming <murrayc@murrayc.com>
Tue, 30 Aug 2011 13:28:06 +0000 (15:28 +0200)
Otherwise the default values are only used if no vfunc is set,
making that default unavailable to vfunc implementations as a fallback,
and unavailable to language bindings (such as gtkmm) that always
have a vfunc implementation, even if that often only tries to call
the base vfunc implemntation.

This was making gtkmm's ToolPalette's (and probably ToolBar's)
items look like buttons instead of being flat.

https://bugzilla.gnome.org/show_bug.cgi?id=656223

gtk/gtktoolshell.c

index 7dc4bf5ac2d7d207d1134702e3ed9948114707bf..82233a567e13dc6772e94145af66dff29f7a715d 100644 (file)
 typedef GtkToolShellIface GtkToolShellInterface;
 G_DEFINE_INTERFACE (GtkToolShell, gtk_tool_shell, GTK_TYPE_WIDGET);
 
+static GtkReliefStyle gtk_tool_shell_real_get_relief_style (GtkToolShell *shell);
+static GtkOrientation gtk_tool_shell_real_get_text_orientation (GtkToolShell *shell);
+static gfloat gtk_tool_shell_real_get_text_alignment (GtkToolShell *shell);
+static PangoEllipsizeMode gtk_tool_shell_real_get_ellipsize_mode (GtkToolShell *shell);
 
 static void
 gtk_tool_shell_default_init (GtkToolShellInterface *iface)
 {
+  iface->get_relief_style = gtk_tool_shell_real_get_relief_style;
+  iface->get_text_orientation = gtk_tool_shell_real_get_text_orientation;
+  iface->get_text_alignment = gtk_tool_shell_real_get_text_alignment;
+  iface->get_ellipsize_mode = gtk_tool_shell_real_get_ellipsize_mode;
+}
+
+static GtkReliefStyle
+gtk_tool_shell_real_get_relief_style (GtkToolShell *shell)
+{
+  return GTK_RELIEF_NONE;
+}
+
+static GtkOrientation
+gtk_tool_shell_real_get_text_orientation (GtkToolShell *shell)
+{
+  return GTK_ORIENTATION_HORIZONTAL;
+}
+
+static gfloat
+gtk_tool_shell_real_get_text_alignment (GtkToolShell *shell)
+{
+  return 0.5f;
+}
+
+static PangoEllipsizeMode
+gtk_tool_shell_real_get_ellipsize_mode (GtkToolShell *shell)
+{
+  return PANGO_ELLIPSIZE_NONE;
 }
 
 
@@ -123,10 +155,7 @@ gtk_tool_shell_get_relief_style (GtkToolShell *shell)
 {
   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
 
-  if (iface->get_relief_style)
-    return iface->get_relief_style (shell);
-
-  return GTK_RELIEF_NONE;
+  return iface->get_relief_style (shell);
 }
 
 /**
@@ -168,10 +197,7 @@ gtk_tool_shell_get_text_orientation (GtkToolShell *shell)
 {
   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
 
-  if (iface->get_text_orientation)
-    return GTK_TOOL_SHELL_GET_IFACE (shell)->get_text_orientation (shell);
-
-  return GTK_ORIENTATION_HORIZONTAL;
+  return iface->get_text_orientation (shell);
 }
 
 /**
@@ -191,10 +217,7 @@ gtk_tool_shell_get_text_alignment (GtkToolShell *shell)
 {
   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
 
-  if (iface->get_text_alignment)
-    return GTK_TOOL_SHELL_GET_IFACE (shell)->get_text_alignment (shell);
-
-  return 0.5f;
+  return iface->get_text_alignment (shell);
 }
 
 /**
@@ -214,10 +237,7 @@ gtk_tool_shell_get_ellipsize_mode (GtkToolShell *shell)
 {
   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
 
-  if (iface->get_ellipsize_mode)
-    return GTK_TOOL_SHELL_GET_IFACE (shell)->get_ellipsize_mode (shell);
-
-  return PANGO_ELLIPSIZE_NONE;
+  return iface->get_ellipsize_mode (shell);
 }
 
 /**